package yjpay.merchant.web.control;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import yjpay.service.MerchantAPIService;

/**
 * 商户通用接口——查询交易订单
 * 
 * @author junqinghuang
 * 
 */
@Controller
public class MerchantQueryOrderWebCtrl {
	@Resource(name = "merchantAPIService")
	private MerchantAPIService merchantAPIService;

	@RequestMapping(value = "/merchant/to_merchant_query_order")
	public String toMerchantQuery() {
		return "merchant/merchant_query_order.jsp";
	}

	@RequestMapping(value = "/merchant/query_order")
	@ResponseBody
	public ModelAndView merchantQueryOrder(
			@RequestParam("query_orderid") String orderid,
			@RequestParam("query_yborderid") String yborderid, Model model)
			throws Exception {

		String res = merchantAPIService.queryOrder(orderid, yborderid);

		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("pay/pay_result.jsp");
		modelAndView.addObject("apiname", "交易订单查询接口（商户通用接口）");
		modelAndView.addObject("payresult_view", res);

		return modelAndView;
	}

}
